<html>
<head><meta charset="utf-8"><title>finding which macro rule to use · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/finding.20which.20macro.20rule.20to.20use.html">finding which macro rule to use</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="220191555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/finding%20which%20macro%20rule%20to%20use/near/220191555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/finding.20which.20macro.20rule.20to.20use.html#220191555">(Dec 17 2020 at 00:08)</a>:</h4>
<p>I'm trying to work on <a href="https://github.com/rust-lang/rust/issues/79908">#79908</a>, and I think the bug might be in the code that selects which rule in a <code>macro_rules!</code> to use. Can someone point me to where that code is?</p>



<a name="220191603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/finding%20which%20macro%20rule%20to%20use/near/220191603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/finding.20which.20macro.20rule.20to.20use.html#220191603">(Dec 17 2020 at 00:09)</a>:</h4>
<p>Would it be in <code>rustc_expand</code>?</p>



<a name="220191673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/finding%20which%20macro%20rule%20to%20use/near/220191673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/finding.20which.20macro.20rule.20to.20use.html#220191673">(Dec 17 2020 at 00:10)</a>:</h4>
<p>Ah maybe this: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/mbe/index.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/mbe/index.html</a></p>



<a name="220240422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/finding%20which%20macro%20rule%20to%20use/near/220240422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/finding.20which.20macro.20rule.20to.20use.html#220240422">(Dec 17 2020 at 13:07)</a>:</h4>
<p>The fix is to change <code>token.can_begin_expr()</code> to <code>token.can_begin_expr() &amp;&amp; !token.is_keyword(kw::Const)</code> in <code>fn nonterminal_may_begin_with</code>.</p>



<a name="220240637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/finding%20which%20macro%20rule%20to%20use/near/220240637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/finding.20which.20macro.20rule.20to.20use.html#220240637">(Dec 17 2020 at 13:09)</a>:</h4>
<p>This is the universal compatibility fix for any additions to FIRST sets of AST fragments (i.e. the <code>can_begin_*</code> functions).</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>